package com.hxd.otc.module.my.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseActivity;
import com.hxd.otc.module.my.bean.NoticeBean;
import com.hxd.otc.module.my.contract.MessageDetailContract;
import com.hxd.otc.module.my.presenter.MessageDetailPresenter;
import com.hxd.otc.utils.GlideUtils;
import com.hxd.otc.utils.UIUtils;
import com.hxd.otc.widget.TitleBar;

import butterknife.BindView;

/**
 * Created by lzy on 2018/6/22 0022.
 * description ${公告详情}
 */
public class AfficheDetailActivity extends BaseActivity<MessageDetailPresenter> implements MessageDetailContract.View {
    public static final String EXTRA_MESSAGE_DETAIL = "messageDetail";
    public static final String EXTRA_POSITION = "position";
    @BindView(R.id.title_bar)
    TitleBar mTitleBar;
    @BindView(R.id.tv_title_real)
    TextView mTvTitle;
    @BindView(R.id.tv_content)
    TextView mTvContent;
    @BindView(R.id.tv_time)
    TextView mTvTime;
    @BindView(R.id.iv_img)
    ImageView mIvImg;
    private NoticeBean mNoticeBean;
    private String mNoticeId;
    private int mPosition;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_affiche_detail;
    }

    @Override
    protected MessageDetailPresenter createPresenter() {
        return new MessageDetailPresenter(this);
    }

    @Override
    protected void initView() {
        Bundle bundle = getBundle();
        mNoticeBean = (NoticeBean) bundle.getSerializable(EXTRA_MESSAGE_DETAIL);
        mPosition = bundle.getInt(EXTRA_POSITION, -1);
        if (mNoticeBean == null) {
            return;
        }

        mNoticeId = mNoticeBean.getId();
        mTvTitle.setText(mNoticeBean.getTitle());
        mTvTime.setText(mNoticeBean.getCreateTime());

        if (TextUtils.isEmpty(mNoticeBean.getPictureUrl())) {// 不显示图片，显示文本
            mTvContent.setVisibility(View.VISIBLE);
            mIvImg.setVisibility(View.GONE);
            mTvContent.setText(mNoticeBean.getContent());
        } else {//显示图片
            mTvContent.setVisibility(View.GONE);
            mIvImg.setVisibility(View.VISIBLE);
            GlideUtils.loadNormal(this, UIUtils.getServiceImageUrlByPath(mNoticeBean.getPictureUrl()), mIvImg);
        }

    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initEvent() {
    }
}
